const router = require('express').Router()
const validateToken = require('../../../common/validateToken')
const status_code = require('../../../common/status_code')

router.post('/auth', (req, resp) => {
  // 从请求头里取出 token
  const rawToken = req.headers.authorization
  // 验证token是否失效
  validateToken(rawToken).then((e) => {
    if (!e) {
      return resp.json({
        msg: status_code['66013'],
        code: 66013,
      })
    }
    resp.json({
      code: 0,
      msg: status_code[0],
      data: e,
    })
  })
})

module.exports = router
